package com.jueming.cashbook.core.response;


/**
 * 全局相应状态码枚举类
 * @author TS
 */
public enum ResultCode {

    /* 参数错误：10001-19999 */
    PARAM_IS_INVALID(10001, "参数无效"),
    PARAM_IS_BLANK(10002, "参数为空"),
    PARAM_TYPE_BIND_ERROR(10003, "参数格式错误"),
    PARAM_NOT_COMPLETE(10004, "参数缺失"),

    /* 用户错误：20001-29999*/
    USER_NOT_LOGGED_IN(20001, "用户未登录，请先登录"),
    USER_LOGIN_ERROR(20002, "账号不存在或密码错误"),
    USER_ACCOUNT_FORBIDDEN(20003, "账号已被禁用"),
    USER_NOT_EXIST(20004, "用户不存在"),
    USER_HAS_EXISTED(20005, "用户工号已存在"),
    USER_ACCTNO_ERROR(20006, "用户账号录入有误,只能包含数字,字母,下划线."),

    /* 业务错误：30001-39999 */
    BUSINESS_GROUP_NO_ALLOWED_DEL(30001, "应用分组已经被应用使用，不能删除"),
    BUSINESS_THEME_NO_ALLOWED_DEL(30002, "主题已经被用户使用，不能删除"),
    BUSINESS_THEME_NO_ALLOWED_DISABLE(30003, "主题已经被用户使用，不能停用"),
    BUSINESS_THEME_DEFAULT_NO_ALLOWED_DEL(30004, "默认主题，不能删除"),
    BUSINESS_THEME_NO_ALLOWED_UPDATE(30005, "主题已经被用户使用，不能修改图片信息"),
    BUSINESS_TYPE_EXISTED(30006, "新增类型已存在!"),
    BUSINESS_TYPE_ADDSTATES(30007, "状态码不正确,不能新增!"),
    BUSINESS_IS_TOP(30040, "已经到最顶部"),
    BUSINESS_IS_BOTTOM(30041, "已经到最底部"),
    BUSINESS_NAME_EXISTED(30051, "名称已存在"),
    BUSINESS_LEVELS_MAX(30051, "数据层级达到最大层数."),
    BUSINESS_CURRENCY_NOT(30052, "当前科目对应的币种关联信息为空,请检查数据!"),
    BUSINESS_FIELDMATCH(30056, "参数值不匹配!"),
    BUSINESS_DEBITNOTEQCREDIT(30057, "借贷不平衡!"),


    /* 系统错误：40001-49999 */
    SYSTEM_INNER_ERROR(40001, "系统繁忙，请稍后重试"),
    UPLOAD_ERROR(40002, "系统异常，上传文件失败"),
    FILE_MAX_SIZE_OVERFLOW(40003, "上传尺寸过大"),
    FILE_ACCEPT_NOT_SUPPORT(40004, "上传文件格式不支持"),
    SET_UP_AT_LEAST_ONE_ADMIN(40005, "至少指定一个管理员"),
    URL_INVALID(40006, "地址不合法"),
    LINK_AND_LOGOUT_NO_MATCH(40006, "主页地址和注销地址IP不一致"),
    IP_AND_PORT_EXISTED(40007, "当前IP和端口已经被占中"),
    LINK_IS_REQUIRED(40008, "生成第三方token认证信息： 主页地址不能为空,请完善信息"),
    ONLY_ROOT_DEPARTMENT(40009, "组织机构只能存在一个根机构"),
    DEPART_CODE_EXISTED(40010, "组织机构编码已存在"),
    DEPART_CONTAINS_USERS(40011, "该机构下是存在用户，不允许删除"),
    DEPART_CONTAINS_SON(40012, "该机构下是存在子级机构，不允许删除"),
    DEPART_PARENT_IS_SELF(40013, "选择的父机构不能为本身"),
    DICT_EXIST_DEPEND(40014, "该字典数据存在详情依赖，不允许删除"),
    DICT_DETAIL_LOCK(40015, "该字典数据被锁定，不允许修改或删除"),
    DEPART_CODE_EXISTED_WITH_ARGS(40016, "组织机构编码【{0}】系统已存在"),
    FILE_NOT_EXISTS(400017, "上传文件不存在"),
    AGENCY_NOT_EXISTS(400017, "机构信息不存在!"),

    /* 数据错误：50001-599999 */
    RESULT_DATA_NONE(50001, "数据未找到"),
    DATA_IS_WRONG(50002, "数据有误"),
    DATA_ALREADY_EXISTED(50003, "数据已存在"),

    /* 接口错误：60001-69999 */
    INTERFACE_INNER_INVOKE_ERROR(60001, "内部系统接口调用异常"),
    INTERFACE_OUTTER_INVOKE_ERROR(60002, "外部系统接口调用异常"),
    INTERFACE_FORBID_VISIT(60003, "该接口禁止访问"),
    INTERFACE_ADDRESS_INVALID(60004, "接口地址无效"),
    INTERFACE_REQUEST_TIMEOUT(60005, "接口请求超时"),
    INTERFACE_EXCEED_LOAD(60006, "接口负载过高"),


    /* 权限错误：70001-79999 */
    PERMISSION_UNAUTHENTICATED(70001,"此操作需要登陆系统！"),
    PERMISSION_UNAUTHORISE(70002,"权限不足，无权操作！"),
    PERMISSION_EXPIRE(70003,"登录状态过期！"),
    PERMISSION_TOKEN_EXPIRED(70004, "token已过期"),
    PERMISSION_LIMIT(70005, "访问次数受限制"),
    PERMISSION_TOKEN_INVALID(70006, "无效token"),
    PERMISSION_SIGNATURE_ERROR(70007, "签名失败"),

    /* 进销存.错误:   80001-89999  */
    JXC_NUMBERS_OUT_ERROR(80001, "数字值录入有误"),
    JXC_SUBJECT_EDITS(80002, "该科目属性为不可删除和不可修改的类型，不允许删除或修改"),
    JXC_WLTYPE_CJNOTFOUND(80003, "物料类型层级定义维护未找到!"),
    JXC_WLTYPE_PDLEVELNUMNOTFOUNT(80004, "父节点的层级数为找到!"),
    JXC_WLTYPE_MOVETHISNOT(80004, "不能移动到当前节点下面!"),
    JXC_WLTYPE_LEVELNUMCHECK(80004, "不能移动到当前父节点,最大层级数不能超过最大层级配置!"),
    JXC_WLTYPE_MOVECHECK_NOTTOCHILD(80004, "选中节点不能移动到自己的子节点下面!"),
    JXC_DELIVERY_SAVE_ERROR(80005,"保存成品送货失败！"),

    /* 在线办公模块.错误:   90001 - 99999  */
    WORK_BOOK_01(90001, "工单类型不能为空!"),
    WORK_BOOK_02(90002, "扭转人不能为空!"),
    WORK_BOOK_03(90003, "子工单类型不能为空!"),
    WORK_BOOK_04(90004, "留言对象(@人)不能为空!"),
    WORK_BOOK_05(90005, "业务类型不是工单,不能新增扭转信息!"),
    WORK_BOOK_06(90006, "非录入状态下,不能删除."),
    WORK_BOOK_07(90007, "非[编辑,中止]状态下,不能发布."),
    WORK_BOOK_071(90007, "非编辑状态下,不能修改."),
    WORK_BOOK_08(90008, "非发布状态下,不能发布撤回."),
    WORK_BOOK_09(90009, "录入状态下不能重新实施!"),
    WORK_BOOK_10(90010, "发布状态下不能重新实施!"),
    WORK_BOOK_11(90011, "不能重复操作!"),
    WORK_BOOK_12(90012, "不能重复任务验收!"),
    WORK_BOOK_13(90013, "未结束的业务不能任务验收!"),
    WORK_BOOK_14(90014, "不能重复任务结束!"),
    WORK_BOOK_15(90015, "非[终止]状态下的业务不能结束!"),
    WORK_BOOK_16(90016, "未任务验收的业务不能任务结束!"),
    WORK_BOOK_17(90017, "录入状态下不能重新实施!"),
    WORK_BOOK_18(90018, "发布状态下不能重新实施!"),
    WORK_BOOK_19(90019, "未任务验收的业务不能取消任务验收"),
    WORK_BOOK_20(90020, "未任务结束的业务不能取消上线撤回"),
    WORK_BOOK_21(90021, "当前状态不允许进行该操作!"),
    WORK_BOOK_22(90022, "不能进行该操作!"),
    WORK_BOOK_23(90023, "类型为【工单】的子节点不能为【任务】"),
    WORK_BOOK_24(90024, "选择父节点在当前被修改记录的子节点下已经存在"),
    WORK_BOOK_25(90024, "子任务大类不能为空!"),
    WORK_BOOK_26(90024, "子任务小类不能为空!"),
    WORK_BOOK_27(90024, "子任务小类记录不存在!"),
    WORK_BOOK_28(90024, "子任务小类记录对应积分小于等于0!"),
    WORK_BOOK_29(90024, "未内验全部通过的记录不能终验合格!"),
    WORK_BOOK_30(90024, "未终验合格的记录不能终验失败!"),
    WORK_BOOK_31(90024, "未终验合格的记录不能任务完结!"),
    WORK_BOOK_32(90024, "未任务完结的记录不能取消任务完结!"),
    WORK_BOOK_PARENT_NOTEXISTS(90100, "父节点记录不存在!"),
    WORK_BOOK_DOESNOT_WITH_YOU(90101, "不能操作他人的扭转记录!"),
    WORK_BOOK_DELETE_TALK_FAIL(90102, "不能删除他人的留言记录!"),
    WORK_BOOK_DELETE_FILE_FAIL(90102, "不能删除他人上传的文件记录!"),


    /****/
    RECORDYEAR_NOT(90103, "年月不能为空!"),
    YGUSERID_NOT_EMPTY(90104, "员工不能为空!"),
    RECORDYEAR_STYLE(90105,"日期格式必须为YYYYMMDD"),


    /* 数据库操作错误  1001 - 9999 */
    SQLEXCEPTION_INSERT(1001, "新增记录异常!"),



    /* 成功状态码 */
    SUCCESS(0,"success"),

    /* 错误状态码 */
    FAIL(-1,"fail"),

    /** 异常  **/
    EXCETPION(-2,"exception");

    //操作代码
    int code;
    //提示信息
    String message;
    ResultCode(int code, String message){
        this.code = code;
        this.message = message;
    }

    public int code() {
        return code;
    }

    public String message() {
        return message;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setMessage(String message) {
        this.message = message;
    }


    public static ResultCode forName(String value) throws Exception {
        ResultCode[] var1 = values();
        int var2 = var1.length;
        for(int var3 = 0; var3 < var2; ++var3) {
            ResultCode alg = var1[var3];
            if (alg.message().equalsIgnoreCase(value)) {
                return alg;
            }
        }
        throw new Exception("Unsupported ResultCode '" + value + "'");
    }


    public static ResultCode forCode(int code) throws Exception {
        ResultCode[] var1 = values();
        int var2 = var1.length;
        for(int var3 = 0; var3 < var2; ++var3) {
            ResultCode alg = var1[var3];
            if (alg.code() == code) {
                return alg;
            }
        }
        throw new Exception("Unsupported ResultCode '" + code + "'");
    }

    /*public static void main(String[] args) throws Exception {
        ResultCode resultCode = forCode(60001);
        System.out.println(resultCode.message());
        System.out.println(resultCode.code);
    }*/

}
